package com.myfoon.helper;

import com.myfoon.model.entity.Event;
import com.myfoon.model.entity.User;

import javax.servlet.http.HttpServletRequest;

public class SessionHelper {
    private HttpServletRequest request;

    public SessionHelper(HttpServletRequest httpServletRequest) {
        this.request = httpServletRequest;
    }

    public void setUser(User user) {
        request.getSession(true).setAttribute("user", user);
    }

    public User getUser() {
        return (request.getSession(true).getAttribute("user") != null ?
                (User)request.getSession(true).getAttribute("user") : null);        
    }
    
    public Integer getTimeZoneOffset() {
        return 0;
        /*
        Object o = request.getSession(true).getAttribute("tz_offset");
        if (o != null) {
            return Integer.parseInt((String)o);
        }
        
        return 0;*/
    }
    
    public Event getEvent() throws Throwable { 
        Event event = new Event();        
        return event;
    }    
}
